/**
 * 功能描述 列表
 */

define(function (require, exports, module) {
	var Grid = require("grid");
	var Dialog = require("dialog");
	var proChangeRoom = require("../constant/fetchProperties");
	var aw = require("ajaxwrapper");
	var Form = require("form");
	
    var instance = {
        initComponent : function (params, widget) {
            var grid = new Grid({
            	parentNode : ".J-editgrid",	
            	url : "api/changeroom/querydetail",
				model : {
				 id : "editgrid",
				 columns  : [{
					 name : "idNumber",
					 label : "身份证号",
				 },{
					 name : "name",
					 label : "姓名",
				 },{
					 name : "sex",
					 label : "性别",
				 },{
					 name : "roomType",
					 label : "房型",
					 format : function(value, data){
						 if(data.change){
							 return value;
						 }
						 if(data.croomType){
							 return data.croomType.name;
						 }else{
							 return value;
						 }
					 },
				 },{
					 name : "roomCode",
					 label : "房号",
					 format : function(value, data){
						 if(data.change){
							 return value;
						 }
						 if(data.croomType){
							 return data.croom.code;
						 }else{
							 return value;
						 }
					 },
				 },{
					name : "croomType.name",
					label : "调整后房型",
					format : function(value, data){
						if(data.change){
							 return value;
						 }
						 if(value){
							 return data.roomType;
						 }else{
							 return "";
						 }
					 },
				 },{
					name : "croom.code",
					label : "调整后房号",
					format : function(value, data){
						 if(data.change){
							 return value;
						 }
						 if(value){
							 return data.roomCode;
						 }else{
							 return "";
						 }
					 },
			     },{
					 name : "changeRoomDate",
					 label : "调整日期",
					 format : function(value){
						 if(value==""){
							 return "";
						 }
						 return moment(value).format("YYYY-MM-DD HH:mm");
					 },
				 },{
						name:"show",
						label:"操作",
						format:"button",
						formatparams:[{
							id:"edit",
							icon:"icon-edit",
							text:"换房",
							handler:function(index,data,rowEle){
								widget.show([".J-roomStatus"]).hide([".J-grid",".J-form",".J-editgrid ",".J-detailgrid"]);
								widget.get("subnav").show(["building","roomType","roomStateReturn"]).hide(["search","servicePoint","destination","time","save","return"]);
								widget.showRooms(index,data);
							}
						},{
							id:"check",
							text:"水电表抄表和房间消费",
							handler:function(index,data,rowEle){
								widget.show([".J-middleform",".J-consumpeditgrid"]).hide([".J-editgrid",".J-form"]);
								widget.get("subnav").show(["consumreturn","consumsave"]).hide(["search","servicePoint","destination","time","save","return"]);
								widget.gridHandler.showConsum(data,widget,true);
								widget.set("roomCode", data.croom ? data.croom.code : data.roomCode);
							}
						}]
					}]
				}
            });
            widget.set("editgrid", grid);
        }
    };
    module.exports = instance;
});
